<template>
  <div>
    <div>
      <span style="font-size: 16px">弹簧设计工具</span>
    </div>
    <div v-loading="loading" element-loading-text="模型生成中">

      <el-tabs v-model="springTabType" type="card">
        <el-tab-pane label="压缩弹簧" name="1">
          <div>
            <el-form label-width="80px">
              <el-form-item label="材料直径 d">
                <el-col>
                  <el-input size="small" v-model="d"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label="有效圈数 n">
                <el-col>
                  <el-input size="small" @blur="handleN" v-model="n"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="弹簧外径 D2">
                <el-col>
                  <el-input size="small" v-model="D2"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label="节距 t">
                <el-col>
                  <el-input :disabled="heightFlag" size="small" v-model="t"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label="高度 H">
                <el-col>
                  <el-input :disabled="!heightFlag" size="small" v-model="H"></el-input>
                  <span>mm</span>
                  <el-checkbox v-model="heightFlag">根据高度</el-checkbox>
                </el-col>
              </el-form-item>
              <el-form-item label="旋向">
                <el-col>
                  <el-select size="small" v-model="rotateDir">
                    <el-option v-for="item in rotateOption" :key="item.value" :label="item.label"
                               :value="item.value"></el-option>
                  </el-select>
                </el-col>
              </el-form-item>
              <el-form-item label="端部结构">
                <el-col>
                  <el-select style="width:210px" size="small" v-model="compressTelosStruct">
                    <el-option v-for="item in compressTelosStructOption" :key="item.value" :label="item.label"
                               :value="item.value"></el-option>
                  </el-select>
                </el-col>
              </el-form-item>
            </el-form>
          </div>
        </el-tab-pane>

        <el-tab-pane label="拉伸弹簧" name="2">
          <div>
            <el-form label-width="80px">
              <el-form-item label="外径 D2">
                <el-col>
                  <el-input size="small" v-model="D2"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label="有效圈数 n">
                <el-col>
                  <el-input size="small" @blur="handleN" v-model="n"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="材料直径 d">
                <el-col>
                  <el-input size="small" v-model="d"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label="节距 t">
                <el-col>
                  <el-input :disabled="heightFlag" size="small" v-model="t"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label="自由长度 H">
                <el-col>
                  <el-input :disabled="!heightFlag" size="small" v-model="H"></el-input>
                  <span>mm</span>
                  <el-checkbox v-model="heightFlag">根据高度</el-checkbox>
                </el-col>
              </el-form-item>
              <el-form-item label="旋向">
                <el-col>
                  <el-select size="small" v-model="rotateDir">
                    <el-option v-for="item in rotateOption" :key="item.value" :label="item.label"
                               :value="item.value"></el-option>
                  </el-select>
                </el-col>
              </el-form-item>
              <el-form-item label="端部结构">
                <el-col>
                  <el-select style="width:210px" size="small" v-model="stretchTelosStruct">
                    <el-option v-for="item in stretchTelosStructOption" :key="item.value" :label="item.label"
                               :value="item.value"></el-option>
                  </el-select>
                </el-col>
              </el-form-item>
            </el-form>
          </div>
        </el-tab-pane>

        <el-tab-pane label="扭转弹簧" name="3">
          <div>
            <el-form label-width="80px">
              <el-form-item label="角度">
                <el-col>
                  <el-input size="small" v-model="angle"></el-input>
                  <span>°</span>
                </el-col>
              </el-form-item>
              <el-form-item label="弹簧外径 D2">
                <el-col>
                  <el-input size="small" v-model="D2"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label="材料直径 d">
                <el-col>
                  <el-input size="small" v-model="d"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label="节距 t">
                <el-col>
                  <el-input :disabled="heightFlag" size="small" v-model="t"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label="有效圈数 n">
                <el-col>
                  <el-input size="small" @blur="handleN" v-model="n"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="自由长度 H">
                <el-col>
                  <el-input :disabled="!heightFlag" size="small" v-model="H"></el-input>
                  <span>mm</span>
                  <el-checkbox v-model="heightFlag">根据高度</el-checkbox>
                </el-col>
              </el-form-item>
              <el-form-item label="扭臂长 L">
                <el-col>
                  <el-input size="small" v-model="L"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
            </el-form>
            <el-form :inline="true">
              <el-form-item label-width="80px" label="半径">
                <el-col>
                  <el-input size="small" style="width: 50px" v-model="radius"></el-input>
                  <span>mm</span>
                </el-col>
              </el-form-item>
              <el-form-item label-width="40px" label="旋向">
                <el-col>
                  <el-select style="width: 70px" size="small" v-model="rotateDir">
                    <el-option v-for="item in rotateOption" :key="item.value" :label="item.label"
                               :value="item.value"></el-option>
                  </el-select>
                </el-col>
              </el-form-item>
            </el-form>
            <el-form label-width="80px">
            <el-form-item label="端部结构">
              <el-col>
                <el-select style="width:210px" size="small" v-model="reverseTelosStruct">
                  <el-option v-for="item in reverseTelosStructOption" :key="item.value" :label="item.label"
                             :value="item.value"></el-option>
                </el-select>
              </el-col>
            </el-form-item>
            </el-form>
          </div>
        </el-tab-pane>

        <el-tab-pane label="截锥弹簧" name="4">
          <div>
            <el-form label-width="80px">
              <el-form-item label="材料直径 d">
                <el-col>
                  <el-input size="small" v-model="d"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="小端圆半径 R1">
                <el-col>
                  <el-input size="small" v-model="R1"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="大端圆半径 R2">
                <el-col>
                  <el-input size="small" v-model="R2"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="有效圈数 n">
                <el-col>
                  <el-input size="small" @blur="handleN" v-model="n"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="自由高度 H">
                <el-col>
                  <el-input size="small" v-model="H"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="旋向">
                <el-col>
                  <el-select size="small" v-model="rotateDir">
                    <el-option v-for="item in rotateOption" :key="item.value" :label="item.label"
                               :value="item.value"></el-option>
                  </el-select>
                </el-col>
              </el-form-item>
            </el-form>
          </div>
        </el-tab-pane>
      </el-tabs>

      <img v-if="springTabType === '1'" class="image" src="/image/compressSpring.jpg">
      <img v-if="springTabType === '2'" class="image" src="/image/stretchSpring.jpg">
      <img v-if="springTabType === '3'" class="image" src="/image/reverseSpring.jpg">
      <img v-if="springTabType === '4'" class="image" src="/image/coneSpring.jpg">

      <div>
        <el-button type="primary" :disabled="loading" @click="createModel">生成</el-button>
      </div>

    </div>
  </div>
</template>

<script>
import {CrownCADPlugin, Point} from "../../../nodeApp/static/lib/crowncad-plugin-sdk-0.0.1";
import {getPointByLen} from "../../util/Common";

export default {
  name: "Spring",
  data() {
    return {
      crownCADPlugin: null,
      springTabType: "1",
      loading: false,

      //压缩弹簧
      //材料直径
      d: 4,
      //有效圈数
      compressNOption: [],
      stretchNOption: [],
      n: 3,
      //弹簧外径
      D2: 45,
      //节距
      t: 14,
      // 高度
      H: 100,
      // 根据高度
      heightFlag: false,
      //旋向
      rotateOption: [
        {
          value: 1,
          label: "右旋"
        },
        {
          value: 0,
          label: "左旋"
        }
      ],
      rotateDir: 1,
      // 端部结构
      compressTelosStruct: 1,
      compressTelosStructOption: [
        {
          value: 1,
          label: "端部不并紧不磨平"
        },
        // {
        //   value: 2,
        //   label: "端部不并紧磨平0.25圈"
        // },
        {
          value: 3,
          label: "端部并紧不磨平,支撑圈为1圈"
        },
        // {
        //   value: 4,
        //   label: "端部不并紧磨平,支撑圈为0.75圈"
        // },
        // {
        //   value: 5,
        //   label: "端部并紧磨平,支撑圈为1圈"
        // },
        // {
        //   value: 6,
        //   label: "端部并紧磨平,支撑圈为1.25圈"
        // },
      ],
      //拉伸弹簧
      stretchTelosStruct: 1,
      stretchTelosStructOption: [
        {
          value: 1,
          label: "圆钩环"
        },
        // {
        //   value: 2,
        //   label: "圆钩环压中心"
        // },
        {
          value: 3,
          label: "偏心圆钩环"
        },
      ],

      reverseTelosStruct: 4,
      reverseTelosStructOption: [
        // {
        //   value: 1,
        //   label: "外臂扭转"
        // },
        {
          value: 2,
          label: "中心臂扭转"
        },
        // {
        //   value: 3,
        //   label: "平列双扭"
        // },
        {
          value: 4,
          label: "直臂扭转"
        },
        // {
        //   value: 5,
        //   label: "单臂弯曲扭转"
        // },
      ],

      //扭转弹簧
      angle: 120,
      //扭臂长
      L: 50,
      //半径
      radius: 6,

      //截锥弹簧
      R1: 10,
      R2: 20,


    }
  },

  mounted() {
    this.initPlugin();
  },

  methods: {
    async initPlugin() {
      this.loading = true;
      this.crownCADPlugin = new CrownCADPlugin();
      this.crownCADPlugin.setParentOrigin("http://localhost:8080");
      this.crownCADPlugin.setMaxAttempt(5);
      this.crownCADPlugin.setLayout(500, 350, 550);
      await this.crownCADPlugin.connect();
      this.loading = false;
    },

    handleN() {
      this.n = Math.floor(this.n);
    },

    async createModel() {
      this.loading = true;
      let frontDatum = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["前视基准面"]);
      let rightDatum = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["右视基准面"]);
      let upDatum = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["上视基准面"]);

      this.frontDatumId = frontDatum.entities[0].id;
      this.rightDatumId = rightDatum.entities[0].id;
      this.upDatumId = upDatum.entities[0].id;

      switch (this.springTabType) {
        case "1":
          await this.createCompressSpring();
          break;
        case "2":
          await this.createStretchSpring();
          break;
        case "3":
          await this.createReverseSpring();
          break;
        case "4":
          await this.createConeSpring();
          break;
      }
      this.loading = false;
    },

    async createCompressSpring() {
      this.crownCADPlugin.command.clearCommand();
      this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图1", datumId: this.frontDatumId});
      let centerPoint = new Point(0, 0, 0);
      let circlePoint = new Point(this.D2 - this.d, 0, 0);
      this.crownCADPlugin.command.sketch.createCircle({centerPoint: centerPoint, circlePoint: circlePoint});
      this.crownCADPlugin.command.sketch.exitSketch();
      await this.crownCADPlugin.command.execute(true);
      this.crownCADPlugin.command.clearCommand();

      let curves = [];
      let res = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图1"]);
      if (res.entities?.length === 0) {
        return;
      }
      let sketchId = res.entities[0].id;
      if (this.heightFlag) {
        this.crownCADPlugin.command.curve.createHelixCurve({
          helixPlane: sketchId,
          inputModel: 2,
          height: this.H,
          revolution: this.n,
          rotation: this.rotateDir,
        }, "螺旋曲线1");
      } else {
        this.crownCADPlugin.command.curve.createHelixCurve({
          helixPlane: sketchId,
          inputModel: 1,
          step: this.t,
          revolution: this.n,
          rotation: this.rotateDir,
        }, "螺旋曲线1");
      }
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();
      curves.push("螺旋曲线1");

      if (this.compressTelosStruct === 2) {
        // this.crownCADPlugin.command.datum.createPlaneByDistance({
        //   planeId: this.frontDatumId,
        //   invertNormal: 0,
        //   paralDis: this.n * this.t - this.d / 2,
        //   reverse: 0,
        // }, "基准面1");
        // await this.crownCADPlugin.command.execute();
        // this.crownCADPlugin.command.clearCommand();
        //
        // let result = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["基准面1"]);
        // if (result.entities?.length === 0) {
        //   return
        // }
        // let datumId = result.entities[0].id;
        // this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图2", datumId: this.frontDatumId});
        // let centerPoint = new Point(0, 0, 0);
        // let circlePoint = new Point(this.D2 * 2, 0, 0);
        // this.crownCADPlugin.command.sketch.createCircle({centerPoint: centerPoint, circlePoint: circlePoint});
        // this.crownCADPlugin.command.sketch.exitSketch();
        // await this.crownCADPlugin.command.execute();
        // this.crownCADPlugin.command.clearCommand();
        //
        // let result1 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["扫描凸台1"]);
        // if (result1.entities?.length === 0) {
        //   return
        // }
        // this.crownCADPlugin.command.solid.extrudeCut({
        //   sketch: "Query.getEntityIdByFeatureName('草图2')",
        //   reverse: 0,
        //   directionType: 0,
        //   extrudeType1: 0,
        //   height1: 10,
        //   toSurface1: 0,
        //   draftType1: -1,
        //   angle1: 0,
        //   extrudeType2: -1,
        //   height2: 0,
        //   toSurface2: 0,
        //   draftType2: -1,
        //   angle2: 0,
        //   offsetType: 0,
        //   distance: this.n * this.t - this.d / 2,
        //   reverseOffset: 0,
        //   cutSolids: [result1.entities[0].id],
        // }, "拉伸切除1")
        // await this.crownCADPlugin.command.execute();
        // this.crownCADPlugin.command.clearCommand();
        //
        // let result2 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["扫描凸台1"]);
        // if (result2.entities?.length === 0) {
        //   return
        // }
        // this.crownCADPlugin.command.solid.extrudeCut({
        //   sketch: "Query.getEntityIdByFeatureName('草图2')",
        //   reverse: 0,
        //   directionType: 0,
        //   extrudeType1: 0,
        //   height1: 10 + this.d / 2,
        //   toSurface1: 0,
        //   draftType1: -1,
        //   angle1: 0,
        //   extrudeType2: -1,
        //   height2: 0,
        //   toSurface2: 0,
        //   draftType2: -1,
        //   angle2: 0,
        //   offsetType: 0,
        //   distance: 10,
        //   reverseOffset: 1,
        //   cutSolids: [result2.entities[0].id],
        // }, "拉伸切除2")
        // console.log(this.crownCADPlugin);
        // debugger
        // await this.crownCADPlugin.command.execute();
        // this.crownCADPlugin.command.clearCommand();
      }
      if (this.compressTelosStruct === 3) {
        let offset = this.n * this.t;
        if (this.heightFlag) {
          offset = parseFloat(this.H);
        }
        this.crownCADPlugin.command.datum.createPlaneByDistance({
          planeId: this.frontDatumId,
          invertNormal: 0,
          paralDis: offset,
          reverse: 0,
        }, "基准面1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let datumInfo = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["基准面1"]);
        if (datumInfo.entities?.length === 0) {
          return
        }
        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图2", datumId: datumInfo.entities[0].id});
        let centerPoint = new Point(0, 0, 0);
        let circlePoint = new Point(this.D2 - this.d, 0, 0);
        this.crownCADPlugin.command.sketch.createCircle({centerPoint: centerPoint, circlePoint: circlePoint});
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let sketch = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图2"]);
        if (sketch.entities?.length === 0) {
          return
        }
        this.crownCADPlugin.command.curve.createHelixCurve({
          helixPlane: sketch.entities[0].id,
          inputModel: 1,
          step: this.d,
          revolution: 1,
          rotation: this.rotateDir,
        }, "螺旋曲线2");
        this.crownCADPlugin.command.curve.createHelixCurve({
          helixPlane: sketchId,
          inputModel: 1,
          step: this.d,
          revolution: 1,
          rotation: this.rotateDir,
          isInvert: 1,
        }, "螺旋曲线3");
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        curves.push("螺旋曲线2");
        curves.push("螺旋曲线3");
      }

      // 组合曲线
      let result1 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(curves);
      if (result1.entities?.length === 0) {
        return
      }
      let ids = [];
      result1.entities.forEach(item => ids.push(item.id))
      this.crownCADPlugin.command.curve.createCompositeCurve({
        JoinEntities: ids
      }, "组合曲线1")
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();

      let result = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["组合曲线1"]);
      if (result.entities?.length === 0) {
        return
      }
      let pathId = result.entities[0].id;
      this.crownCADPlugin.command.solid.sweep({
        sweepType: 1,
        sweepPath: [pathId],
        radius: this.d / 2,
      }, "扫描凸台1")
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();
    },

    async createStretchSpring() {
      //绘制螺旋曲线基础草图圆
      this.crownCADPlugin.command.clearCommand();
      this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图1", datumId: this.frontDatumId});
      let centerPoint = new Point(0, 0, 0);
      let circlePoint = new Point(this.D2 - this.d, 0, 0);
      this.crownCADPlugin.command.sketch.createCircle({centerPoint: centerPoint, circlePoint: circlePoint});
      this.crownCADPlugin.command.sketch.exitSketch();
      await this.crownCADPlugin.command.execute(true);
      this.crownCADPlugin.command.clearCommand();
      // 创建螺旋曲线
      let res = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图1"]);
      if (res.entities?.length === 0) {
        return;
      }
      let sketchId = res.entities[0].id;
      if (this.heightFlag) {
        this.crownCADPlugin.command.curve.createHelixCurve({
          helixPlane: sketchId,
          inputModel: 2,
          height: this.H,
          revolution: this.n,
          rotation: this.rotateDir,
        }, "螺旋曲线1");
      } else {
        this.crownCADPlugin.command.curve.createHelixCurve({
          helixPlane: sketchId,
          inputModel: 1,
          step: this.t,
          revolution: this.n,
          rotation: this.rotateDir,
        }, "螺旋曲线1");
      }
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();
      // 绘制一侧弯曲两草图，进行投影曲线
      if (this.stretchTelosStruct === 1) {
        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图2", datumId: this.upDatumId})
        let centerPnt = new Point(this.D2 - this.d, this.D2 - this.d, 0);
        let startPnt = new Point(0, this.D2 - this.d, 0);
        let endPnt = new Point(this.D2 - this.d, 0, 0);
        this.crownCADPlugin.command.sketch.createArcByCenter({
          centerPoint: centerPnt, startPoint: startPnt, endPoint: endPnt
        })
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图3", datumId: this.frontDatumId})
        let centerPnt1 = new Point(0, 0, 0);
        let startPnt1 = new Point(0, -(this.D2 - this.d), 0);
        let endPnt1 = new Point(this.D2 - this.d, 0, 0);
        if (this.rotateDir === 1) {
          this.crownCADPlugin.command.sketch.createArcByCenter({
            centerPoint: centerPnt1, startPoint: startPnt1, endPoint: endPnt1
          })
        } else {
          let newStartPnt = new Point(0, this.D2 - this.d, 0);
          this.crownCADPlugin.command.sketch.createArcByCenter({
            centerPoint: centerPnt1, startPoint: endPnt1, endPoint: newStartPnt
          })
        }
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let sketchRes = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图2", "草图3"]);
        if (sketchRes.entities?.length !== 2) {
          return
        }
        this.crownCADPlugin.command.curve.createProjectCurve({
          projectionType: 2,
          sketches: [sketchRes.entities[0].id, sketchRes.entities[1].id],
          doubleDirection: 1,
        }, "投影曲线")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        // 绘制两侧半圆弯钩曲线,并投影为曲线
        let offset = this.d * this.n;
        if (this.heightFlag) {
          offset = parseFloat(this.H);
        }
        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图4", datumId: this.rightDatumId})
        let centerPnt2 = new Point(this.D2 - this.d, 0, 0);
        let startPnt2 = new Point(this.D2 - this.d, -(this.D2 - this.d), 0);
        let endPnt2 = new Point(this.D2 - this.d, this.D2 - this.d, 0);
        this.crownCADPlugin.command.sketch.createArcByCenter({
          centerPoint: centerPnt2, startPoint: startPnt2, endPoint: endPnt2
        })
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let sketchRes2 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图4"]);
        if (sketchRes2.entities?.length === 0) {
          return
        }
        this.crownCADPlugin.command.curve.createProjectCurve({
          projectionType: 1,
          sketches: [sketchRes2.entities[0].id],
          faces: [this.rightDatumId],
        }, "投影曲线2")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        //绘制另一侧弯曲两个草图,并偏移基准面,进行投影曲线
        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图5", datumId: this.upDatumId})
        let centerPnt3 = new Point(this.D2 - this.d, -(offset + this.D2 - this.d), 0);
        let startPnt3 = new Point(this.D2 - this.d, -offset, 0);
        let endPnt3 = new Point(0, -(offset + this.D2 - this.d), 0);
        this.crownCADPlugin.command.sketch.createArcByCenter({
          centerPoint: centerPnt3, startPoint: startPnt3, endPoint: endPnt3
        })
        this.crownCADPlugin.command.sketch.exitSketch();
        this.crownCADPlugin.command.datum.createPlaneByDistance({
          planeId: this.frontDatumId,
          invertNormal: 0,
          paralDis: offset,
          reverse: 0,
        }, "基准面1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let datum = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["基准面1"]);
        if (datum.entities?.length === 0) {
          return
        }
        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图6", datumId: datum.entities[0].id})
        let centerPnt4 = new Point(0, 0, 0);
        let startPnt4 = new Point(this.D2 - this.d, 0, 0);
        let endPnt4 = new Point(0, this.D2 - this.d, 0);
        if (this.rotateDir === 1) {
          this.crownCADPlugin.command.sketch.createArcByCenter({
            centerPoint: centerPnt4, startPoint: startPnt4, endPoint: endPnt4
          })
        } else {
          let newStartPoint = new Point(0, -(this.D2 - this.d), 0);
          this.crownCADPlugin.command.sketch.createArcByCenter({
            centerPoint: centerPnt4, startPoint: newStartPoint, endPoint: startPnt4
          })
        }
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let sketchRes3 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图5", "草图6"]);
        if (sketchRes3.entities?.length !== 2) {
          return
        }
        this.crownCADPlugin.command.curve.createProjectCurve({
          projectionType: 2,
          sketches: [sketchRes3.entities[0].id, sketchRes3.entities[1].id],
          doubleDirection: 1,
        }, "投影曲线3")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        // 绘制一侧半圆弯钩
        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图7", datumId: this.rightDatumId})
        let centerPnt5 = new Point(-(offset + this.D2 - this.d), 0, 0);
        let startPnt5 = new Point(-(offset + this.D2 - this.d), this.D2 - this.d, 0);
        let endPnt5 = new Point(-(offset + this.D2 - this.d), -(this.D2 - this.d), 0);
        this.crownCADPlugin.command.sketch.createArcByCenter({
          centerPoint: centerPnt5, startPoint: startPnt5, endPoint: endPnt5
        })
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let sketchRes4 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图7"]);
        if (sketchRes4.entities?.length === 0) {
          return
        }
        this.crownCADPlugin.command.curve.createProjectCurve({
          projectionType: 1,
          sketches: [sketchRes4.entities[0].id],
          faces: [this.rightDatumId],
        }, "投影曲线4")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        // 组合曲线
        let result = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["螺旋曲线1", "投影曲线", "投影曲线2", "投影曲线3", "投影曲线4"]);
        if (result.entities?.length === 0) {
          return
        }
        let ids = [];
        result.entities.forEach(item => ids.push(item.id))
        this.crownCADPlugin.command.curve.createCompositeCurve({
          JoinEntities: ids
        }, "组合曲线1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
      } else if (this.stretchTelosStruct === 3) {
        this.crownCADPlugin.command.clearCommand();
        this.crownCADPlugin.command.datum.createPlaneByDistance({
          planeId: this.rightDatumId,
          invertNormal: 0,
          paralDis: this.D2 - this.d,
          reverse: 0,
        }, "基准面1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let datumInfo = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["基准面1"]);
        if (datumInfo.entities?.length === 0) {
          return
        }

        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图2", datumId: datumInfo.entities[0].id})
        let centerPnt = new Point(this.D2 - this.d, 0, 0);
        let startPnt = new Point(0, 0, 0);
        let endPnt = new Point(this.D2 - this.d, this.D2 - this.d, 0);
        if (this.rotateDir === 1) {
          this.crownCADPlugin.command.sketch.createArcByCenter({centerPoint: centerPnt, startPoint: startPnt, endPoint: endPnt})
        } else {
          let newStartPoint = new Point(this.D2 - this.d, -(this.D2 - this.d), 0);
          this.crownCADPlugin.command.sketch.createArcByCenter({centerPoint: centerPnt, startPoint: newStartPoint, endPoint: startPnt})
        }
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let offset = this.d * this.n;
        if (this.heightFlag) {
          offset = parseFloat(this.H);
        }
        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图3", datumId: datumInfo.entities[0].id})
        let centerPnt1 = new Point(-(offset + this.D2 - this.d), 0, 0);
        let startPnt1 = new Point(-offset, 0, 0);
        let endPnt1 = new Point(-(offset + this.D2 - this.d), -(this.D2 - this.d), 0);
        if (this.rotateDir === 1) {
          this.crownCADPlugin.command.sketch.createArcByCenter({centerPoint: centerPnt1, startPoint: startPnt1, endPoint: endPnt1})
        } else {
          let newStartPoint = new Point(-(offset + this.D2 - this.d), this.D2 - this.d, 0);
          this.crownCADPlugin.command.sketch.createArcByCenter({centerPoint: centerPnt1, startPoint: newStartPoint, endPoint: startPnt1})
        }
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let sketchRes2 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图2"]);
        if (sketchRes2.entities?.length === 0) {
          return
        }
        this.crownCADPlugin.command.curve.createProjectCurve({
          projectionType: 1,
          sketches: [sketchRes2.entities[0].id],
          faces: [datumInfo.entities[0].id],
        }, "投影曲线1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let sketchRes3 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图3"]);
        if (sketchRes3.entities?.length === 0) {
          return
        }
        this.crownCADPlugin.command.curve.createProjectCurve({
          projectionType: 1,
          sketches: [sketchRes3.entities[0].id],
          faces: [datumInfo.entities[0].id],
        }, "投影曲线2")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let result = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["螺旋曲线1", "投影曲线1", "投影曲线2"]);
        if (result.entities?.length === 0) {
          return
        }
        let ids = [];
        result.entities.forEach(item => ids.push(item.id))
        this.crownCADPlugin.command.curve.createCompositeCurve({
          JoinEntities: ids
        }, "组合曲线1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
      }
      //扫描曲线
      let result2 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["组合曲线1"]);
      if (result2.entities?.length === 0) {
        return
      }
      let pathId = result2.entities[0].id;
      this.crownCADPlugin.command.solid.sweep({
        sweepType: 1,
        sweepPath: [pathId],
        radius: this.d / 2,
      }, "扫描凸台1")
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();
    },

    async createReverseSpring() {
      if (this.angle < 0 || this.angle > 180) {
        this.$message({
          message: '角度范围0°-180°',
          type: 'error',
          duration: 1000
        });
        return;
      }

      this.crownCADPlugin.command.clearCommand();
      this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图1", datumId: this.frontDatumId});
      let centerPoint = new Point(0, 0, 0);
      let circlePoint = new Point(this.D2 - this.d, 0, 0);
      this.crownCADPlugin.command.sketch.createCircle({centerPoint: centerPoint, circlePoint: circlePoint});
      this.crownCADPlugin.command.sketch.exitSketch();
      await this.crownCADPlugin.command.execute(true);
      this.crownCADPlugin.command.clearCommand();

      // 创建螺旋曲线
      let res = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图1"]);
      if (res.entities?.length === 0) {
        return;
      }

      let curveNames = [];
      let newN = 0;
      let newAngle = 180 - this.angle;
      if (this.reverseTelosStruct === 4 || this.reverseTelosStruct === 5) {
        newN = 0.5 * newAngle / 180;
      }

      let sketchId = res.entities[0].id;
      if (this.heightFlag) {
        this.crownCADPlugin.command.curve.createHelixCurve({
          helixPlane: sketchId,
          inputModel: 2,
          height: this.H,
          revolution: this.n + newN,
          rotation: this.rotateDir,
        }, "螺旋曲线1");
      } else {
        this.crownCADPlugin.command.curve.createHelixCurve({
          helixPlane: sketchId,
          inputModel: 1,
          step: this.t,
          revolution: this.n + newN,
          rotation: this.rotateDir,
        }, "螺旋曲线1");
      }
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();
      curveNames.push("螺旋曲线1");

      if (this.reverseTelosStruct === 4) {
        let point1 = new Point(this.D2 - this.d, 0, 0);
        let point2 = new Point(this.D2 - this.d, -this.L, 0);
        if (this.rotateDir === 0) {
          point2 = new Point(this.D2 - this.d, this.L, 0);
        }
        this.crownCADPlugin.command.curve.createCurveByXYZPoints({points: [point1, point2]}, "投影曲线1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        curveNames.push("投影曲线1");

        let result1 = await this.crownCADPlugin.query.getElementsByFeatureNames(["螺旋曲线1"]);
        if (result1.elements.length === 0) {
          return;
        }
        let element = result1.elements.find(item => item.type === 8);
        let curveEndPoint = element.params.endPoint;
        let startPoint = new Point(curveEndPoint[0],curveEndPoint[1],curveEndPoint[2]);
        let startDir = new THREE.Vector3(curveEndPoint[0],curveEndPoint[1],curveEndPoint[2]);
        let endPoint;
        if (newAngle > 0 && newAngle < 90) {
          let l = (this.D2 - this.d) / Math.cos((90 - newAngle) / 180 * Math.PI)
          let endDir = new THREE.Vector3(0, l, curveEndPoint[2]);
          if (this.rotateDir === 0) {
            endDir = new THREE.Vector3(0, -l, curveEndPoint[2]);
          }
          let dir = endDir.clone().sub(startDir).normalize();
          let end = getPointByLen(startDir, dir, this.L);
          endPoint = new Point(end.x, end.y, end.z);
        } else if (newAngle > 90 && newAngle < 180) {
          let l = (this.D2 - this.d) / Math.cos((180 - newAngle) / 180 * Math.PI)
          let endDir = new THREE.Vector3(-l, 0, curveEndPoint[2]);
          let dir = endDir.clone().sub(startDir).normalize();
          let end = getPointByLen(startDir, dir, this.L);
          endPoint = new Point(end.x, end.y, end.z);
        } else if (newAngle === 0) {
          startPoint = new Point(curveEndPoint[0],0,curveEndPoint[2]);
          endPoint = new Point(curveEndPoint[0], this.L, curveEndPoint[2]);
          if (this.rotateDir === 0) {
            endPoint = new Point(curveEndPoint[0], -this.L, curveEndPoint[2]);
          }
        } else if (newAngle === 90) {
          startPoint = new Point(0,curveEndPoint[1],curveEndPoint[2]);
          endPoint = new Point(-this.L, curveEndPoint[1], curveEndPoint[2]);
        } else if (newAngle === 180) {
          startPoint = new Point(curveEndPoint[0],0,curveEndPoint[2]);
          endPoint = new Point(curveEndPoint[0], -this.L, curveEndPoint[2]);
          if (this.rotateDir === 0) {
            endPoint = new Point(curveEndPoint[0], this.L, curveEndPoint[2]);
          }
        }
        this.crownCADPlugin.command.curve.createCurveByXYZPoints({points: [startPoint, endPoint]}, "曲线1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        curveNames.push("曲线1");
      } else if (this.reverseTelosStruct === 2) {
        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图2", datumId: this.upDatumId})
        let centerPnt = new Point(this.D2 - this.d, this.D2 - this.d, 0);
        let startPnt = new Point(0, this.D2 - this.d, 0);
        let endPnt = new Point(this.D2 - this.d, 0, 0);
        this.crownCADPlugin.command.sketch.createArcByCenter({
          centerPoint: centerPnt, startPoint: startPnt, endPoint: endPnt
        })
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图3", datumId: this.frontDatumId})
        let centerPnt1 = new Point(0, 0, 0);
        let startPnt1 = new Point(0, -(this.D2 - this.d), 0);
        let endPnt1 = new Point(this.D2 - this.d, 0, 0);
        if (this.rotateDir === 1) {
          this.crownCADPlugin.command.sketch.createArcByCenter({
            centerPoint: centerPnt1, startPoint: startPnt1, endPoint: endPnt1
          })
        } else {
          let newStartPnt = new Point(0, this.D2 - this.d, 0);
          this.crownCADPlugin.command.sketch.createArcByCenter({
            centerPoint: centerPnt1, startPoint: endPnt1, endPoint: newStartPnt
          })
        }
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let sketchRes = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图2", "草图3"]);
        if (sketchRes.entities?.length !== 2) {
          return
        }
        this.crownCADPlugin.command.curve.createProjectCurve({
          projectionType: 2,
          sketches: [sketchRes.entities[0].id, sketchRes.entities[1].id],
          doubleDirection: 1,
        }, "投影曲线1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        curveNames.push("投影曲线1");
        //绘制另一侧弯曲两个草图,并偏移基准面,进行投影曲线
        let result1 = await this.crownCADPlugin.query.getElementsByFeatureNames(["螺旋曲线1"]);
        if (result1.elements.length === 0) {
          return;
        }
        let element = result1.elements.find(item => item.type === 8);
        let curveEndPoint = element.params.endPoint;
        let offset = curveEndPoint[2];

        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图5", datumId: this.upDatumId})
        let centerPnt3 = new Point(this.D2 - this.d, -(offset + this.D2 - this.d), 0);
        let startPnt3 = new Point(this.D2 - this.d, -offset, 0);
        let endPnt3 = new Point(0, -(offset + this.D2 - this.d), 0);
        this.crownCADPlugin.command.sketch.createArcByCenter({
          centerPoint: centerPnt3, startPoint: startPnt3, endPoint: endPnt3
        })
        this.crownCADPlugin.command.sketch.exitSketch();
        this.crownCADPlugin.command.datum.createPlaneByDistance({
          planeId: this.frontDatumId,
          invertNormal: 0,
          paralDis: offset,
          reverse: 0,
        }, "基准面1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let datum = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["基准面1"]);
        if (datum.entities?.length === 0) {
          return
        }
        this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图6", datumId: datum.entities[0].id})
        let centerPnt4 = new Point(0, 0, 0);
        let startPnt4 = new Point(this.D2 - this.d, 0, 0);
        let endPnt4 = new Point(0, this.D2 - this.d, 0);
        if (this.rotateDir === 1) {
          this.crownCADPlugin.command.sketch.createArcByCenter({
            centerPoint: centerPnt4, startPoint: startPnt4, endPoint: endPnt4
          })
        } else {
          let newStartPoint = new Point(0, -(this.D2 - this.d), 0);
          this.crownCADPlugin.command.sketch.createArcByCenter({
            centerPoint: centerPnt4, startPoint: newStartPoint, endPoint: startPnt4
          })
        }
        this.crownCADPlugin.command.sketch.exitSketch();
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();

        let sketchRes3 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图5", "草图6"]);
        if (sketchRes3.entities?.length !== 2) {
          return
        }
        this.crownCADPlugin.command.curve.createProjectCurve({
          projectionType: 2,
          sketches: [sketchRes3.entities[0].id, sketchRes3.entities[1].id],
          doubleDirection: 1,
        }, "投影曲线3")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        curveNames.push("投影曲线3");
      } else if (this.reverseTelosStruct === 5) {
        let point1 = new Point(this.D2 - this.d, 0, 0);
        let point2 = new Point(this.D2 - this.d, -this.L, 0);
        if (this.rotateDir === 0) {
          point2 = new Point(this.D2 - this.d, this.L, 0);
        }
        this.crownCADPlugin.command.curve.createCurveByXYZPoints({points: [point1, point2]}, "投影曲线1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        curveNames.push("投影曲线1");

        let result1 = await this.crownCADPlugin.query.getElementsByFeatureNames(["螺旋曲线1"]);
        if (result1.elements.length === 0) {
          return;
        }
        let element = result1.elements.find(item => item.type === 8);
        let curveEndPoint = element.params.endPoint;
        let startPoint = new Point(curveEndPoint[0],curveEndPoint[1],curveEndPoint[2]);
        let startDir = new THREE.Vector3(curveEndPoint[0],curveEndPoint[1],curveEndPoint[2]);
        let endPoint;
        if (newAngle > 0 && newAngle < 90) {
          let l = (this.D2 - this.d) / Math.cos((90 - newAngle) / 180 * Math.PI)
          let endDir = new THREE.Vector3(0, l, curveEndPoint[2]);
          if (this.rotateDir === 0) {
            endDir = new THREE.Vector3(0, -l, curveEndPoint[2]);
          }
          let dir = endDir.clone().sub(startDir).normalize();
          let end = getPointByLen(startDir, dir, this.L);
          endPoint = new Point(end.x, end.y, end.z);
        } else if (newAngle > 90 && newAngle < 180) {
          let l = (this.D2 - this.d) / Math.cos((180 - newAngle) / 180 * Math.PI)
          let endDir = new THREE.Vector3(-l, 0, curveEndPoint[2]);
          let dir = endDir.clone().sub(startDir).normalize();
          let end = getPointByLen(startDir, dir, this.L);
          endPoint = new Point(end.x, end.y, end.z);
        } else if (newAngle === 0) {
          startPoint = new Point(curveEndPoint[0],0,curveEndPoint[2]);
          endPoint = new Point(curveEndPoint[0], this.L, curveEndPoint[2]);
          if (this.rotateDir === 0) {
            endPoint = new Point(curveEndPoint[0], -this.L, curveEndPoint[2]);
          }
        } else if (newAngle === 90) {
          startPoint = new Point(0,curveEndPoint[1],curveEndPoint[2]);
          endPoint = new Point(-this.L, curveEndPoint[1], curveEndPoint[2]);
        } else if (newAngle === 180) {
          startPoint = new Point(curveEndPoint[0],0,curveEndPoint[2]);
          endPoint = new Point(curveEndPoint[0], -this.L, curveEndPoint[2]);
          if (this.rotateDir === 0) {
            endPoint = new Point(curveEndPoint[0], this.L, curveEndPoint[2]);
          }
        }
        this.crownCADPlugin.command.curve.createCurveByXYZPoints({points: [startPoint, endPoint]}, "曲线1")
        await this.crownCADPlugin.command.execute();
        this.crownCADPlugin.command.clearCommand();
        curveNames.push("曲线1");
      }

      let result = await this.crownCADPlugin.query.getEntitiesByFeatureNames(curveNames);
      if (result.entities?.length === 0) {
        return
      }
      let ids = [];
      result.entities.forEach(item => ids.push(item.id))
      this.crownCADPlugin.command.curve.createCompositeCurve({
        JoinEntities: ids
      }, "组合曲线1")
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();

      //扫描曲线
      let result2 = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["组合曲线1"]);
      if (result2.entities?.length === 0) {
        return
      }
      let pathId = result2.entities[0].id;
      this.crownCADPlugin.command.solid.sweep({
        sweepType: 1,
        sweepPath: [pathId],
        radius: this.d / 2,
      }, "扫描凸台1")
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();

    },

    async createConeSpring() {
      //绘制螺旋曲线基础草图圆
      this.crownCADPlugin.command.clearCommand();
      this.crownCADPlugin.command.sketch.createSketch({sketchName: "草图1", datumId: this.frontDatumId});
      let centerPoint = new Point(0, 0, 0);
      let circlePoint = new Point(this.R2 - this.d, 0, 0);
      this.crownCADPlugin.command.sketch.createCircle({centerPoint: centerPoint, circlePoint: circlePoint});
      this.crownCADPlugin.command.sketch.exitSketch();
      await this.crownCADPlugin.command.execute(true);
      this.crownCADPlugin.command.clearCommand();
      // 创建螺旋曲线
      let res = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["草图1"]);
      if (res.entities?.length === 0) {
        return;
      }

      let taperAngle = 90 - Math.atan(this.H / (this.R2 - this.R1)) * 180 / Math.PI;
      let sketchId = res.entities[0].id;
        this.crownCADPlugin.command.curve.createHelixCurve({
          helixPlane: sketchId,
          inputModel: 2,
          height: this.H,
          revolution: this.n,
          rotation: this.rotateDir,
          isTaperAngle: 1,
          taperAngle: taperAngle,
        }, "螺旋曲线1");
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();

      //扫描曲线
      let result = await this.crownCADPlugin.query.getEntitiesByFeatureNames(["螺旋曲线1"]);
      if (result.entities?.length === 0) {
        return
      }
      let pathId = result.entities[0].id;
      this.crownCADPlugin.command.solid.sweep({
        sweepType: 1,
        sweepPath: [pathId],
        radius: this.d / 2,
      }, "扫描凸台1")
      await this.crownCADPlugin.command.execute();
      this.crownCADPlugin.command.clearCommand();
    },

  },

  watch: {
    springTabType() {
      switch (this.springTabType) {
        case "1":
          this.d = 4;
          this.n = 3;
          this.D2 = 45;
          this.t = 14;
          this.H = 100;
          this.rotateDir = 1;
          this.compressTelosStruct = 1;
          break;
        case "2":
          this.D2 = 18;
          this.n = 10;
          this.d = 3;
          this.t = 3;
          this.H = 100;
          this.rotateDir = 1;
          this.stretchTelosStruct = 1;
          break;
        case "3":
          this.angle = 120;
          this.D2 = 22;
          this.d = 4;
          this.t = 5;
          this.n = 3;
          this.H = 50;
          this.L = 50;
          this.radius = 6;
          this.rotateDir = 1;
          this.stretchTelosStruct = 1;
          break;
        case "4":
          this.d = 2;
          this.R1 = 10;
          this.R2 = 20;
          this.n = 4;
          this.H = 25;
          this.rotateDir = 1;
          break;
      }
      this.heightFlag = false;
    },
  }
}
</script>

<style scoped>
.label {
    font-size: 10px;
    font-weight: bold;
}

.splitLine {
    border: 1px solid #dae0e5;
    margin: 2px;
    width: 480px;
}

>>> .el-form-item {
    margin-bottom: 2px;
    margin-left: 4px;
}

>>> .el-form-item__label {
    font-size: 10px;
    line-height: 30px;
}

>>> .el-input__inner {
    padding: 2px 4px;
    font-size: 10px;
    line-height: 2px;
}

.el-input {
    width: 100px;
}

.el-select {
    width: 100px;
}

>>> .el-form-item__content {
    line-height: 30px;
}

>>> .el-button {
    margin: 4px;
    font-size: 8px;
}

.el-select-dropdown__item {
    padding: 2px 2px;
}

>>> .el-tabs__header {
    margin: 0 0 2px;
    padding: 2px 2px;
}

>>> .el-tabs__item {
    padding: 0 15px;
    height: 30px;
    line-height: 30px;
    font-size: 10px;
}

.image {
    height: 150px;
    width: 150px;
}
</style>